from django.db import models

# Create your models here.

class OptionModel(models.Model):
    '''
    选项模型(包含A、B、C、D四个选项，与题目模型一对一关系)
    '''
    A = models.CharField(max_length=100) # 选项A
    B = models.CharField(max_length=100) # 选项B
    C = models.CharField(max_length=100) # 选项C
    D = models.CharField(max_length=100) # 选项D

class QuestionModel(models.Model):
    '''
    题目模型
    '''
    question = models.CharField(max_length=200) # 题目
    options = models.OneToOneField( # 选项
        OptionModel, # 选项模型
        on_delete=models.CASCADE, # 级联删除
        related_name='question' # 选项
        ) # 选项
    answer = models.CharField(max_length=10) # 答案
